#include <iostream>
#include <fstream>

#define filename    "./test.txt"

int main(void)
{
    std::fstream fs;
    fs.open(filename, std::ios::in);
    if (! fs.is_open())
    {
        std::cout << "文件不存在，创建该文件" << std::endl;
        fs.open(filename, std::ios::out);
        if(fs.is_open())
        {
            std::cout << "创建文件成功" << std::endl;
            fs.close();
        }
        else
        {
            std::cout << "创建文件失败" << std::endl;
            fs.close();
        }
    }
    else
    {
        std::cout << "文件存在，删除该文件" << std::endl;
        fs.close();

        if(remove(filename)==0)
        {
            std::cout << "删除成功" << std::endl;
        }
        else
        {
            std::cout << "删除失败" << std::endl;
        }
    }
    
    return 0;
}
